﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.ComponentModel;
using System.Windows.Controls;

namespace MockupDesigner.Items
{
    public class ProgressBarItem : ResizableItem
    {

        // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(double), typeof(ProgressBarItem));

        [Category("Prop_Content")]
        public double Value
        {
            get { return (double)GetValue(ValueProperty); }
            set
            {
                if (this.Value == value) return;
                OnPropertyChanging("Value", this.Value, value);
                SetValue(ValueProperty, value);
                OnPropertyChanged("Value");
            }
        }

        public static readonly DependencyProperty OrientationProperty =
            DependencyProperty.Register("Orientation", typeof(Orientation), typeof(ProgressBarItem));

        private const double INIT_VAL = -10;

        private double oldHeight = INIT_VAL;
        private double oldWidth = INIT_VAL;
        //[Category("Prop_Content")]
        public Orientation Orientation
        {
            get { return (Orientation)GetValue(OrientationProperty); }
            set
            {
                if (this.Orientation == value) return;
                OnPropertyChanging("Orientation", this.Orientation, value);
                SetValue(OrientationProperty, value);
                if (this.oldHeight == INIT_VAL)
                {
                    this.autochanging = true;
                    oldHeight = this.Height;
                    oldWidth = this.Width;
                    this.Height = oldWidth;
                    this.Width = oldHeight;
                    this.autochanging = false;
                }
                else
                {
                    this.oldHeight = INIT_VAL;
                    this.oldWidth = INIT_VAL;
                }
                OnPropertyChanged("Orientation");
            }
        }
    }
}
